<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/11/6
 * Time: 14:37
 */
namespace app\api\controller;
use think\App;

/**
 * 商城商品
 *
 * Class Goods
 * @package app\api\controller
 */
class Goods extends BaseController
{
    protected $goodsModel;
    public function __construct(App $app = null)
    {
        parent::__construct($app);
        $this->goodsModel = new \app\api\model\Goods();
    }

    /**
     * 获取商品列表
     *
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function getGoodsList()
    {
        $result = $this->goodsModel->goodsList();
        AjaxReturn($result['code'],$result['msg'],$result['data']);
    }

    /**
     * 购买矿山
     *
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function buyGoods()
    {
        //$result = $this->goodsModel->addRecommendNum(4);
        $result = $this->goodsModel->buyGoods($this->uid);
        AjaxReturn($result['code'],$result['msg'],$result['data']);
    }
}